package db_server

import (
	"gitee.com/ljfirst/algo-go-protal/integration/db/db_entity"
	_ "github.com/go-sql-driver/mysql"
	"github.com/go-xorm/xorm"
	"log"
)

/**
 * @author ljfirst
 * @version V1.0
 * @date 2023/9/7 20:43
 * @author-Email ljfirst@mail.ustc.edu.cn
 * @blogURL https://blog.csdn.net/ljfirst
 * @description
 **/

func DBConn() {
	x, err := xorm.NewEngine("mysql", "mysql_user:pwdMysql*2023@tcp(118.195.234.62:3306)/algo_db?charset=utf8")
	if err != nil {
		log.Fatalf("conn database error: %v\n", err)
	}
	err1 := x.Sync2(new(db_entity.AlgoSolution))
	if err1 != nil {
		log.Fatalf("Fail to sync database: %v\n", err1)
	}
}
